<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		
		
		<div>
		    <label for="birthday">生日：</label>
		    <input type="text" name="birthday" id="birthday" />
		    <button id="btn-ok">确定</button>
		    <p id="show"></p>
		</div>
		<script>
		  window.onload = function () {
		      document.getElementById("btn-ok").onclick = function () {
		          var txt_birth = document.getElementById("birthday").value;
		          var birthday = new Date(txt_birth);
		          var now = new Date();
		          var days = Math.floor((now - birthday) / 1000 / 60 / 60 / 24);
		          document.getElementById("show").textContent =
		            "你已经在地球上生活了" + days + "天！";
		      };
		  };
		</script>
	</body>
</html>
